universal schema.tex (2628B)
1 \begin{tikzpicture}[ 2 user/.style={text width=2cm, anchor=west, inner sep=0mm}, 3 item/.style={anchor=south west, inner sep=0mm,rotate=45}, 4 braced/.style={decorate,decoration={brace,amplitude=2mm}}, 5 known/.style={fill=Dark2-A!30,minimum width=1.5cm,minimum height=1cm}, 6 predicted/.style={fill=Dark2-B!30,minimum width=1.5cm,minimum height=1cm}, 7 unknown/.style={fill=Dark2-C!30,minimum width=1.5cm,minimum height=1cm}, 8 ] 9 \NewDocumentCommand\epairhead{m m m}{ 10 \pgfmathparse{-#1+0.5} 11 \node[user] (userh#1) at (-1.7, \pgfmathresult) {\footnotesize#2\textsubscript{\(e_1\)}\\#3\textsubscript{\(e_2\)}}; 12 \coordinate (user#1) at (0, \pgfmathresult); 13 } 14 \NewDocumentCommand\surfacehead{m m}{ 15 \pgfmathparse{1.5*#1-1} 16 \node[item] (itemh#1) at (\pgfmathresult, 0) {\footnotesize``\(e_1\) #2 \(e_2\)''}; 17 \pgfmathparse{1.5*#1-0.75} 18 \coordinate (item#1) at (\pgfmathresult, 0); 19 } 20 \NewDocumentCommand\relationhead{m m}{ 21 \pgfmathparse{1.5*#1-1} 22 \node[item] (itemh#1) at (\pgfmathresult, 0) {\footnotesize\(e_1\mathop{\textsl{#2\/}}e_2\)}; 23 \pgfmathparse{1.5*#1-0.75} 24 \coordinate (item#1) at (\pgfmathresult, 0); 25 } 26 27 \NewDocumentCommand\matrixvalue{m m m m}{ 28 \node[#1] at (user#2-|item#3) {#4}; 29 } 30 31 \epairhead{1}{Ferguson}{Harvard} 32 \epairhead{2}{Oman}{Oxford} 33 \epairhead{3}{Firth}{Oxford} 34 \epairhead{4}{Gödel}{Princeton} 35 \surfacehead{1}{professor at} 36 \surfacehead{2}{historian at} 37 \relationhead{3}{employee of} 38 \relationhead{4}{member of} 39 40 \draw[braced] (2.95, -4.1) -- (0, -4.1) node[midway,below,yshift=-2mm] {Surface forms}; 41 \draw[braced] (6, -4.1) -- (3.05, -4.1) node[midway,below,yshift=-2mm] {Relations}; 42 43 \draw[braced] (-1.8, -4) -- (-1.8, 0) node[midway,left,xshift=-2mm] {\rotatebox{90}{Entity pairs}}; 44 45 \draw[braced] (6.1, 0) -- (6.1, -1.95) node[midway,right,xshift=2mm] {\rotatebox{-90}{Train}}; 46 \draw[braced] (6.1, -2.05) -- (6.1, -4) node[midway,right,xshift=2mm] {\rotatebox{-90}{Test}}; 47 48 \matrixvalue{known}{1}{2}{1}; 49 \matrixvalue{known}{1}{3}{1}; 50 \matrixvalue{known}{1}{4}{1}; 51 \matrixvalue{known}{2}{1}{1}; 52 \matrixvalue{known}{2}{2}{1}; 53 \matrixvalue{known}{3}{2}{1}; 54 \matrixvalue{known}{4}{1}{1}; 55 56 \matrixvalue{predicted}{3}{1}{0.95}; 57 \matrixvalue{predicted}{3}{3}{0.97}; 58 \matrixvalue{predicted}{3}{4}{0.95}; 59 \matrixvalue{predicted}{4}{2}{0.05}; 60 \matrixvalue{predicted}{4}{3}{0.93}; 61 \matrixvalue{predicted}{4}{4}{0.97}; 62 63 \matrixvalue{unknown}{1}{1}{}; 64 \matrixvalue{unknown}{2}{3}{}; 65 \matrixvalue{unknown}{2}{4}{}; 66 67 \draw (0, 0) grid[xstep=1.5,ystep=1] (6, -4); 68 \draw[ultra thick] (3, 0) -- (3, -4); 69 \draw[ultra thick] (0, -2) -- (6, -2); 70 \end{tikzpicture}